//
//  AppleScriptSnapshot.m
//  Shion
//
//  Created by Chris Karr on 12/28/07.
//  Copyright 2007-2008 Audacious Software. All rights reserved.
//

#import "AppleScriptSnapshot.h"
#import "SnapshotController.h"
#import "ShionAppDelegate.h"

@implementation AppleScriptSnapshot

@synthesize snapshot;

- (NSString *) name
{
	return snapshot.name;
}

- (NSScriptObjectSpecifier *) objectSpecifier 
{
	NSArray * devices = [[NSApp delegate] valueForKey:@"snapshots"];
	
    unsigned index = [devices indexOfObjectIdenticalTo:self];
	
    if (index != NSNotFound) 
	{
		NSScriptObjectSpecifier * containerRef = [NSApp objectSpecifier];

        return [[[NSIndexSpecifier alloc] initWithContainerClassDescription:[containerRef keyClassDescription] 
			containerSpecifier:containerRef key:@"snapshots" index:index] autorelease];
    }
	else
        return nil;
}

-(void) activate:(NSScriptCommand *) command
{
	NSMutableDictionary * dict = [NSMutableDictionary dictionary];
	[dict setValue:snapshot.name forKey:SNAPSHOT_NAME];
	
	[[NSNotificationCenter defaultCenter] postNotificationName:ACTIVATE_SNAPSHOT object:self userInfo:dict];
}

@end
